package com.lili.goods.controller;

import com.lili.goods.service.GoodsUnitService;
import com.lili.model.goods.GoodsUnit;
import com.lili.common.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/goods")
@Api(tags = "商品单位")
public class GoodsUnitController {
    @Autowired
    GoodsUnitService goodsService;

    @ApiOperation("商品单位查询")
    @GetMapping("/unit")
    public Result getGoodsUnit() {
        List<GoodsUnit> list = goodsService.getUnit();
        return Result.ok(list);
    }

    @ApiOperation("商品单位保存")
    @PostMapping("/unit")
    public Result saveGoodsUnit(@RequestBody GoodsUnit goodsUnit) {
        int i = goodsService.saveUnit(goodsUnit);
        return Result.ok("保存成功" + i);
    }


    @ApiOperation("商品单位更新")
    @PutMapping("/unit")
    public Result updateGoodsUnit(@RequestBody GoodsUnit goodsUnit) {
        int i = goodsService.updateUnit(goodsUnit);
        return Result.ok("更新成功" + i);
    }


    @ApiOperation("商品单位删除")
    @DeleteMapping("/unit")
    public Result deleteGoodsUnit(@RequestBody GoodsUnit goodsUnit) {
        int i = goodsService.deleteUnit(goodsUnit);
        return Result.ok("删除成功" + i);
    }


}
